<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
    <title>WeUI</title>
    <link rel="stylesheet" href="../css/weui.css"/>
    <link rel="stylesheet" href="../css/login.css"/>
    <link rel="stylesheet" href="./example.css"/>
    <script src="../js/jquery-2.1.1.min.js"></script>
    <script src="../js/jquery.form.min.js"></script>
    <script src="../js/main.js"></script>
    <script src="../layer/layer.js"></script>
    <title>登录</title>
</head>
<body>

<div id="d" style="padding-bottom:29%;width:100%;height:0;margin-top: 1rem;">
    <img src="../img/hube2.png" style="height: auto;width: 100%;"/>

</div>


<div class="page" style="background-color: #ffffff;margin-top: 7rem;">


    <div class="page__bd" style="width: 90%; margin: auto auto;">
        <form method="post" id="ajForm">
            <div class="weui-cells weui-cells_form">

                <div class="weui-cell">
                    <div class="weui-cell__hd">账号:</div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" name="username" type="text" placeholder=""/>
                    </div>
                    <img src="../img/login/check.png">
                </div>

                <div class="weui-cell">
                    <div class="weui-cell__hd">密码:</div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" name="password" type="password" pattern="[0-9A-Za-z.]*"/>
                    </div>
                    <img src="../img/login/yingcang.png">
                </div>
            </div>


            <div class="weui-cell">
                <div id="link-div">
                    <div class="link-a">
                        <a href="forgetPassword.html">忘记密码</a>
                    </div>
                    <div class="link-a" style="float: right">
                        <a href="releaseInfo.html">注册账号</a>
                    </div>
                </div>
            </div>


            <div class="weui-btn-area">
                <input type="submit" class="weui-btn weui-btn_primary" id="showTooltips" value="登录"/>
            </div>

        </form>
    </div>
</div>
<script>
    $.ajaxSetup({
        xhrFields: {
            withCredentials: isCrossDomain
        }
    });
    $(function () {
        var options = {
            // 规定把请求发送到那个URL
            url: mainurl+"v4/login",
            // 请求方式
            type: "post",
            // 服务器响应的数据类型
            dataType: "json",
            beforeSubmit: function (formData, jqForm, options) {
                for(i=0; i<formData.length; i++) {
                    if(formData[i].value==''){
                        warnInfo("用户名或密码不能为空");
                        return false;
                    }
                }

                // if(formData[0].value==''||formData[1].value=='') {
                //     warnInfo("用户名和密码不能为空");
                //     return false
                // }
                return true;
            },
            // 请求成功时执行的回调函数
            success: function(data, status, xhr) {
                if(checkData(data)) {
                    successInfo("登录成功");
                    window.location.href='index.html';
                }
            }
        };
        $("#ajForm").ajaxForm(options);
    });
</script>
</body>
</html>
